/*
 * Qinlan Shen
 * November 8, 2010
 * Pd. 8
 * 
 * Script, based off of Yukari's Border of Wave and Particle.  Difficulty and time limit
 * can be adjusted.
 * 
 */

import java.awt.Image;
import java.util.*;

public class BorderWaveParticle extends RoseScript
{
	private double radius;
	private double angle;
	private double angleAccel;
	private int frame2;
	
	public BorderWaveParticle(int d, int t)
	{
		super (d-7, t);
		radius = 0;
		angle = 0;
		angleAccel = 0;
		frame2 = 0;
	}
	
	public ArrayList<PointItem> run(Rose rose, Character player, int frame, ArrayList<Enemy> enemies, ArrayList<PointItem> points, ArrayList<Image> packets, Image point)
	{
		incrementTime(frame);
		frame2++;

		rose.moveUsingFrames(320, 410, 120);
		
		if(frame > 120)
		{
			for (int i = 0; i < difficulty; i++)
			{
				if(frame % 2 == 0)
					enemies.add(new PacketSA(packets.get(4), 3, (int)Math.round(rose.getX() + radius * Math.sin(angle)), (int)Math.round(rose.getY() + radius * Math.cos(angle)), 2, angle));
				angle += 360/(difficulty);
			}
			angle += angleAccel;
			angleAccel += .05;

			if (frame2 >= -140 && frame2 <= 110)
				radius+= .001;
			if (frame2 >= 111 && frame2 <= 360)
				radius-= .001;
			if (frame2 == 360)
				frame2=-141;
			
			if (time < 0)
				points = endScript(point, rose, player, enemies);
						
		}	
		
		return points;

	}
}